<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>baidu</title>
</head>
<body>

    <div align="center">
    <h2>黑马一下</h2>
    <input id="searchText" type="text" name="search"/>
    &nbsp;&nbsp;<input type="submit" value="搜索"/>
        <div>
            <li id="li_id" hidden="hidden">

            </li>
        </div>
    </div>


</body>

<script src="${pageContext.request.contextPath}/static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script type="text/javascript">

    $(function () {

        $("#searchText").keyup(function () {
            var searchText = $("#searchText").val();
            //var data = { "searchText" : searchText};
            $.get("${pageContext.request.contextPath}/demo/list",{"searchText":searchText},function (result) {
                if(result) {
                    $(result).each(function (i,n) {
                        //$("#li_id").html("<ul></ul>");
                        $("#li_id").appendChild("<ul>"+n.text+"</ul>");

                    });

                }
            },"json")
        });



    })

</script>


</html>
